﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace _2011DBProject
{
    public partial class Join : System.Web.UI.Page
    {
        DataSet1 ds = new DataSet1();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                DataSet1TableAdapters.ACCOUNTTableAdapter taAcc = new DataSet1TableAdapters.ACCOUNTTableAdapter();
                taAcc.Connection.ConnectionString = Settings.strConnectionString;
                if (taAcc.FillByACCOUNT_ID(ds.ACCOUNT, txtID.Text.Trim()) == 0)
                {
                    DataSet1.ACCOUNTRow r = ds.ACCOUNT.NewACCOUNTRow();
                    r.ACCOUNT_ID = txtID.Text.Trim();
                    r.ADDRESS = txtAddr.Text.Trim();
                    r.EMAIL = txtEmail.Text.Trim();
                    r.NAME = txtName.Text.Trim();
                    r.PASSWORD = txtPassword.Text.Trim();
                    r.SSN = txtSSN.Text.Trim();
                    r.PARTNER_SITE_NO = Convert.ToDecimal(ddSite.SelectedValue);
                    r.GRADE_NO = 1;
                    r.SSN = "1";
                    ds.ACCOUNT.AddACCOUNTRow(r);
                    taAcc.Update(ds.ACCOUNT);
                    Response.Redirect("Default.aspx?isJoin=1");
                }
                else
                {
                    string script = "<script>alert('중복된 아이디가 있습니다!!');</script>";
                    Page.ClientScript.RegisterClientScriptBlock(typeof(string), "confirm", script);
                }

                //형열형가르침.
                //taAcc.Fill(ds.ACCOUNT);
                //foreach (DataSet1.ACCOUNTRow r in ds.ACCOUNT)
                //{
                    
                //}
                //ds.ACCOUNT.FindByACCOUNT_ID("1").SSN;
            }
            catch (Exception ex)
            {
                string script = "<script>alert('에러번호 - #01 : 관리자에게 문의하세요.');</script>";
                Page.ClientScript.RegisterClientScriptBlock(typeof(string), "confirm", script);
            }
        }
    }
}
